package com.design.pattern.creator.singleton.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 */
public class ContainerSingleton {
    private  ContainerSingleton(){}
    private static Map<String, Object> ioc = new ConcurrentHashMap<>();

    public static Object getInstance(String className){
        if(!ioc.containsKey(className)) {
            try {
                Object o = Class.forName(className).newInstance();
                ioc.put(className, o);
            }catch(Exception e) {

            }
        }
        return ioc.get(className);
    }
}
